package cn.com.customer.manager.ui.customer.detail

import cn.com.customer.manager.bean.CustomerInfo
import cn.com.customer.manager.bean.RequestBean
import cn.com.customer.manager.http.BaseApi
import cn.com.customer.manager.http.subscriber.TipRequestSubscriber
import com.xuexiang.xhttp2.XHttp
import com.xuexiang.xhttp2.model.ApiResult

class CustomerDetailPresenter constructor(view: CustomerDetailContract.View) : CustomerDetailContract.Presenter {

    var mView: CustomerDetailContract.View = view
    val request = XHttp.custom()
    override fun getData(params: MutableMap<String, String>) {

        request.call(request.create(BaseApi.Customer::class.java)
                .customerDetail(RequestBean(params)))
                .subscribeWith(object : TipRequestSubscriber<ApiResult<CustomerInfo>?>() {
                    override fun onSuccess(apiResult: ApiResult<CustomerInfo>?) {
                        apiResult?.let {
                            if (it.data != null) {
                                mView.setData(it.data)
                            }
                        }
                    }
                })
    }


    override fun start() {


    }

}